package com.qiangqiang.taskuser.mapper.provider;

/**
 * @author : sky
 * @date : 2018/7/14
 * @description :
 */
public class BaseProvider {

    protected final static String DOT = ",";
    protected final static String UPDATE=" ON DUPLICATE KEY UPDATE ";
    protected final static String USER=" user_info ";

    protected final static String UPSERT = "insert into user_info(user_id,nick_name,sex,school,campus,dormitory,head_img_url,create_time," +
            "update_time,email,password,phone) values(#{user.userId},#{user.nickName},#{user.sex},#{user.school},#{user.campus},#{user.dormitory}," +
            "#{user.headImgUrl},#{user.createTime},#{user.updateTime},#{user.email},#{user.password},#{user.phone})";

    protected final static String GET_NICK_NAME="select nick_name from user_info where user_id in (";

    protected final static String GET_NICK_NAME_DTO="select user_id,nick_name from user_info where user_id in (";

    protected String getLimit(int page, int pageSize) {
        StringBuffer sb = new StringBuffer();
        if (page > 0 && pageSize > 0) {
            sb.append("limit ").append((page - 1) * pageSize).append(DOT + pageSize);
        }
        return sb.toString();
    }
}
